diff --git a/baposter.cls b/baposter.cls
index 76afe49bd0ea51fe0e08052a0bc60a73561f7661..28418364f1e159d3107510400457356b607ecd4c 100644
--- a/baposter.cls
+++ b/baposter.cls
@@ -1,185 +1,230 @@
-  %%
-  %% This is file `baposter.cls'
-  %%
-  %% A relatively comfortable latex class to produce posters with a grid based
-  %% layout. It comes with a number of combinable styles and is (maybe only for
-  %% the writer) easy to extend, as all the graphics is based on pgf.
-  %%
-  %% It is meant to be used with pdftex, but might also work with pslatex if you
-  %% are not interested in things like transparency.
-  %%
-  %% Copyright (C) 2007-2010 Brian Amberg
-  %%
-  %% 07. April 2011: Fixed paper size handling
-  %%     - Fixed Paper Size handling, you can now specify all page sizes using paperwidth=, paperheight= class options.
-  %%     - Added rudimentary documentation of the available keys.
-  %% 11. December 2010: Fixed "Empty Second Page" bug
-  %%     - A second empty page was introduced when a document ended with
-  %%           \end{poster}
-  %%         \end{document}
-  %%       This was fixed thanks to a suggestion by Martin Aulbach
-  %%     - Added
-  %%         \thispagestyle{empty}
-  %%       to suppress page numbers, which became visible when the margins are large.
-  %%       The underlying problem of page-size handling has not yet been solved.
-  %% 30. September 2010: Border Bugfixes
-  %%     - Correct background color with textborder=rounded-small, Thanks to Ke Chen for the bugreport and patch
-  %%     - Correctly draw rectangular text boxes, Thanks to abenkst for the bugreport and fix
-  %% 10. June 2010: Added option to set the number of columns
-  %%     - added a class option to set the number of columns
-  %%         - columns=5: sets the number of columns to 5, possible values are 1..6, default is 3 in portrait and 4 in landscape format
-  %% 29. April 2009: Incorporated Patches by Arne Henningsen
-  %%     - added some class options
-  %%        - a4shrink: shrink the paper to A4 size (for printing drafts or handouts)
-  %%        - movebody=Xpt: move the text/poster body Xpt to the right
-  %%                    (or to the left if Xpt is negative),
-  %%                    e.g. for manually centering the poster on the page
-  %%        - showframe: use the "showframe" option of the "geometry" package
-  %%        - a0paper (default): set paper size to A0
-  %%        - archE: set paper size to Arch E
-  %%     - setting "background" can be "none" now (otherwise the "showframe"
-  %%          option has no effect)
-  %%     - the page number has been removed (it was mostly not visible before)
-  %%     - the "margin=" option works now
-  %% 04. December 2008
-  %%     - Mainly an update to the landscape example
-  %% 14. November 2008
-  %%     - Actually center the title when eyecatcher is used.
-  %% 04. November 2008
-  %%     - Fixed bug with eyecatcher not working.
-  %% 26. June 2008
-  %%     - Fixed bug with plain background mode.
-  %% 14. June 2008
-  %%     - Support for portrait/landscape switching.
-  %%     - Some smaller bugfixes.
-  %% 01. June 2007
-  %%     - First version released.
-  %%
-  %% Use this class with pdflatex
-  %%
-  %% I have confirmed that this package works with
-  %%   - texlive 2007 and
-  %%   - miktex 2.7
-  %%
-  %% It does not seem to work with
-  %%   - miktex 2.2
-  %%   - some old versions of tetex
-  %%
-  %% Licence: GPL
-  \ProvidesClass{baposter}[2011/04/07 v1.10 baposter class]
-  \NeedsTeXFormat{LaTeX2e}[1995/06/01]
-  \LoadClass{article}
-  \typeout{baposter: Brian Amberg, 2007, 2008, 2009, 2010, 2011 | http://www.brian-amberg.de/uni/poster/}
-
-  %% Define lengths only once on inclusion, such that we can make multiple posters
-  \newlength{\baposter@basepaperwidth}
-  \newlength{\baposter@basepaperheight}
-  \newlength{\baposter@basemargin}
-  \newlength{\baposter@finalpaperwidth}
-  \newlength{\baposter@finalpaperheight}
-  \newlength{\baposter@finalmargin}
-  \newlength{\headerheight}%
-  \newlength{\colwidth}%
-  \newlength{\colheight}%
-  \newlength{\baposter@@colspacing}%
-  \newlength{\boxstartx}%
-  \newlength{\boxstarty}%
-  \newlength{\boxwidth}%
-  \newlength{\boxheight}%
-  \newlength{\baposter@titleimage@left@width}%
-  \newlength{\baposter@titleimage@right@width}%
-  \newlength{\baposter@titleimage@textwidth}%
-  \newbox\baposter@content%
-  \newbox\baposter@titleimage@left%
-  \newbox\baposter@titleimage@title%
-  \newbox\baposter@titleimage@right%
-
-  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-  % Packages
-  %-------------------------------------------------------------------------------
-  % The only ``weird'' dependency of this package is pgf. All the rest should be
-  % installed on any decent system.
-  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-  \typeout{Use Packages}
-  \usepackage{xkeyval}
-  \usepackage{calc}
-  \usepackage[cmyk,table]{xcolor}
-  \usepackage{tikz}
-  \usepackage{pgf}
-  \usepackage{ifthen}
-  \usepackage[T1]{fontenc}
-
-  \usetikzlibrary{decorations}
-
-  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-  % Settings
-  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-  % TODO: Add package options
-  \typeout{Setup}
-
-  % Choose a smaller value for larger fonts
-  \newcommand{\baposter@fontscale}{0.292}
-  % use the ``showframe'' option of the ``geometry'' package?
-  \newcommand{\baposter@showframe}{false}
-
-  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-  % Zoom
-  %-------------------------------------------------------------------------------
-  % We scale the page from fontscale * papersize up to papersize
-  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-  \typeout{Zoom}
-
-  \newif\iflandscape
-  \DeclareOptionX{landscape}{\landscapetrue}
-  \DeclareOptionX{portrait}{}
-
-  \newcommand{\baposter@setfinalpapersize}[2]{\setlength{\baposter@finalpaperwidth}{#1}\setlength{\baposter@finalpaperheight}{#2}}
-  \baposter@setfinalpapersize{841mm}{1189mm}
-
-  \DeclareOptionX{archE}{  \baposter@setfinalpapersize{91.44cm}{121.92cm}}
-  \DeclareOptionX{paperwidth}[841mm]{\setlength{\baposter@finalpaperwidth}{#1}}
-  \DeclareOptionX{paperheight}[1189mm]{\setlength{\baposter@finalpaperheight}{#1}}
-  \DeclareOptionX{a0paper}{\baposter@setfinalpapersize{841mm}{1189mm}}
-  \DeclareOptionX{a1paper}{\baposter@setfinalpapersize{594mm}{841mm}}
-  \DeclareOptionX{a2paper}{\baposter@setfinalpapersize{420mm}{594mm}}
-  \DeclareOptionX{a3paper}{\baposter@setfinalpapersize{297mm}{420mm}}
-  \DeclareOptionX{a4paper}{\baposter@setfinalpapersize{210mm}{297mm}}
-  \DeclareOptionX{a4paper}{\baposter@setfinalpapersize{210mm}{297mm}}
-
-  \DeclareOptionX{showframe}{\renewcommand{\baposter@showframe}{true}}
-
-  \setlength{\baposter@finalmargin}{1.5cm}
-  \DeclareOptionX{fontscale}[0.292]{\renewcommand{\baposter@fontscale}{#1}}
-  \DeclareOptionX{margin}   [1.5cm]{\setlength{\baposter@finalmargin}{#1}}
-
-  % move text/poster body to the right (or to the left if negative)
-  \newlength{\baposter@movebody}
-  \setlength{\baposter@movebody}{0cm}
-  \DeclareOptionX{movebody}[0cm]{\setlength{\baposter@movebody}{#1}}
-  \ProcessOptionsX
-
-  \iflandscape
-  \typeout{Swapping paper sizes}
-  \newlength{\baposter@swappapersizes}
-  \setlength{\baposter@swappapersizes}{\baposter@finalpaperwidth}
-  \setlength{\baposter@finalpaperwidth}{\baposter@finalpaperheight}
-  \setlength{\baposter@finalpaperheight}{\baposter@swappapersizes}
-  \fi
+%%
+%% This is file `baposter.cls'
+%%
+%% A relatively comfortable latex class to produce posters with a grid based
+%% layout. It comes with a number of combinable styles and is (maybe only for
+%% the writer) easy to extend, as all the graphics is based on pgf.
+%%
+%% It is meant to be used with pdftex, but might also work with pslatex if you
+%% are not interested in things like transparency.
+%%
+%% Copyright (C) 2007-2010 Brian Amberg
+%% Copyright (C) 2011      Reinhold Kainhofer <reinhold@kainhofer.com>
+%%
+%% 27. August 2011 (rk):
+%%     - Completely factored out all drawing commands to handler functions, assigned via choice keys
+%%     - Added cornerradius, boxheaderheight, boxpadding options
+%%     - Added missing roundedright 
+%% 26. August 2011 (rk):
+%%     - Turned headerbox cmd into posterbox environment (allows verbatim)
+%%     - pass several options to packages
+%%     - added debug cls option to reduce default output
+%%     - rewrote several loops and ifthenelse
+%%     - Use boolean and choice keys for all options
+%%     - Changed all choice options to set a global function to
+%%       \baposter@OPTION@OPTIONVALUE, which are a functions that execute the
+%%       option's setting (drawing routine, color setting for tikz, etc.)
+%%     - Add a5paper
+%% 07. April 2011: Fixed paper size handling
+%%     - Fixed Paper Size handling, you can now specify all page sizes using paperwidth=, paperheight= class options.
+%%     - Added rudimentary documentation of the available keys.
+%% 11. December 2010: Fixed "Empty Second Page" bug
+%%     - A second empty page was introduced when a document ended with
+%%           \end{poster}
+%%         \end{document}
+%%       This was fixed thanks to a suggestion by Martin Aulbach
+%%     - Added
+%%         \thispagestyle{empty}
+%%       to suppress page numbers, which became visible when the margins are large.
+%%       The underlying problem of page-size handling has not yet been solved.
+%% 30. September 2010: Border Bugfixes
+%%     - Correct background color with textborder=rounded-small, Thanks to Ke Chen for the bugreport and patch
+%%     - Correctly draw rectangular text boxes, Thanks to abenkst for the bugreport and fix
+%% 10. June 2010: Added option to set the number of columns
+%%     - added a class option to set the number of columns
+%%         - columns=5: sets the number of columns to 5, possible values are 1..6, default is 3 in portrait and 4 in landscape format
+%% 29. April 2009: Incorporated Patches by Arne Henningsen
+%%     - added some class options
+%%        - a4shrink: shrink the paper to A4 size (for printing drafts or handouts)
+%%        - movebody=Xpt: move the text/poster body Xpt to the right
+%%                    (or to the left if Xpt is negative),
+%%                    e.g. for manually centering the poster on the page
+%%        - showframe: use the "showframe" option of the "geometry" package
+%%        - a0paper (default): set paper size to A0
+%%        - archE: set paper size to Arch E
+%%     - setting "background" can be "none" now (otherwise the "showframe"
+%%          option has no effect)
+%%     - the page number has been removed (it was mostly not visible before)
+%%     - the "margin=" option works now
+%% 04. December 2008
+%%     - Mainly an update to the landscape example
+%% 14. November 2008
+%%     - Actually center the title when eyecatcher is used.
+%% 04. November 2008
+%%     - Fixed bug with eyecatcher not working.
+%% 26. June 2008
+%%     - Fixed bug with plain background mode.
+%% 14. June 2008
+%%     - Support for portrait/landscape switching.
+%%     - Some smaller bugfixes.
+%% 01. June 2007
+%%     - First version released.
+%%
+%% Use this class with pdflatex
+%%
+%% I have confirmed that this package works with
+%%   - texlive 2007 and
+%%   - miktex 2.7
+%%
+%% It does not seem to work with
+%%   - miktex 2.2
+%%   - some old versions of tetex
+%%
+%%
+%% TODO:
+%% -) Rename backgrounds back to shaded-tb shade-lr
+%% -) Rename textborder back to rounded-small (consistent naming needed!)
+%% -) Rename headershade back to shade-lr, shade-tb, shade-tb-inverse
+%% -) Rename headershape back to small-rounded
+%% -) Option value consistency (small-rounded vs. rounded-small; missing ones)
+%% -) Rename \baposterDrawPosterBackground, \baposterTextborder, \baposterBoxShade,
+%%    \baposterHeaderSetShade, \baposterHeaderDrawText to include @ and verb
+%%
+%%
+%% Licence: GPL
+\ProvidesClass{baposter}[2011/08/25 v2.0 baposter class]
+\NeedsTeXFormat{LaTeX2e}[1995/06/01]
+\LoadClass{article}
+\typeout{baposter: Brian Amberg, 2007, 2008, 2009, 2010, 2011 | http://www.brian-amberg.de/uni/poster/}
+\typeout{baposter: Reinhold Kainhofer, 2011 | http://reinhold.kainhofer.com/}
+
+%% Define lengths only once on inclusion, such that we can make multiple posters
+\newlength{\baposter@basepaperwidth}
+\newlength{\baposter@basepaperheight}
+\newlength{\baposter@basemargin}
+\newlength{\baposter@finalpaperwidth}
+\newlength{\baposter@finalpaperheight}
+\newlength{\baposter@finalmargin}
+\newlength{\headerheight}%
+\newlength{\colwidth}%
+\newlength{\colheight}%
+\newlength{\baposter@@colspacing}%
+\newlength{\baposter@@cornerradius}%
+\newlength{\baposter@@boxheaderheight}%
+\newlength{\baposter@@boxpadding}%
+\newlength{\boxstartx}%
+\newlength{\boxstarty}%
+\newlength{\boxwidth}%
+\newlength{\boxheight}%
+\newlength{\baposter@titleimage@left@width}%
+\newlength{\baposter@titleimage@right@width}%
+\newlength{\baposter@titleimage@textwidth}%
+\newbox\baposter@content%
+\newbox\baposter@titleimage@left%
+\newbox\baposter@titleimage@title%
+\newbox\baposter@titleimage@right%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Packages
+%-------------------------------------------------------------------------------
+% The only ``weird'' dependency of this package is pgf. All the rest should be
+% installed on any decent system.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\typeout{Use Packages}
+\RequirePackage{xkeyval}
+\RequirePackage{calc}
+\RequirePackage[cmyk]{xcolor}
+\RequirePackage{tikz}
+\RequirePackage{pgf}
+\RequirePackage{ifthen}
+\RequirePackage[T1]{fontenc}
+
+\usetikzlibrary{decorations}
+\usetikzlibrary{fadings}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Settings
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% TODO: Add package options
+
+% Choose a smaller value for larger fonts
+\newcommand{\baposter@fontscale}{0.292}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Zoom
+%-------------------------------------------------------------------------------
+% We scale the page from fontscale * papersize up to papersize
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%% Paper sizes
+\newif\if@landscape
+\DeclareOptionX{landscape}{\@landscapetrue}
+\DeclareOptionX{portrait}{}
+
+\newcommand{\baposter@setfinalpapersize}[2]{\setlength{\baposter@finalpaperwidth}{#1}\setlength{\baposter@finalpaperheight}{#2}}
+\baposter@setfinalpapersize{841mm}{1189mm}
+
+\DeclareOptionX{archE}{\baposter@setfinalpapersize{91.44cm}{121.92cm}}
+\DeclareOptionX{paperwidth}[841mm]{\setlength{\baposter@finalpaperwidth}{#1}}
+\DeclareOptionX{paperheight}[1189mm]{\setlength{\baposter@finalpaperheight}{#1}}
+\DeclareOptionX{a0paper}{\baposter@setfinalpapersize{841mm}{1189mm}}
+\DeclareOptionX{a1paper}{\baposter@setfinalpapersize{594mm}{841mm}}
+\DeclareOptionX{a2paper}{\baposter@setfinalpapersize{420mm}{594mm}}
+\DeclareOptionX{a3paper}{\baposter@setfinalpapersize{297mm}{420mm}}
+\DeclareOptionX{a4paper}{\baposter@setfinalpapersize{210mm}{297mm}}
+\DeclareOptionX{a5paper}{\baposter@setfinalpapersize{148.5mm}{210mm}}
+
+\setlength{\baposter@finalmargin}{1.5cm}
+\DeclareOptionX{fontscale}[0.292]{\renewcommand{\baposter@fontscale}{#1}}
+\DeclareOptionX{margin}   [1.5cm]{\setlength{\baposter@finalmargin}{#1}}
+
+% move text/poster body to the right (or to the left if negative)
+\newlength{\baposter@movebody}
+\setlength{\baposter@movebody}{0cm}
+\DeclareOptionX{movebody}[0cm]{\setlength{\baposter@movebody}{#1}}
+
+
+\newif\if@debug
+\DeclareOptionX{debug}{\@debugtrue}
+%% Will be passed on to other packages (xcolor and geometry), still we don't want unused warnings
+\DeclareOptionX{table}{}
+\DeclareOptionX{showframe}{}
+
+\ProcessOptionsX
+
+
+\if@debug
+\newcommand{\debug}[1]{\typeout{#1}}
+\else
+\newcommand{\debug}[1]{}
+\fi
+
+
+\if@landscape
+\debug{Swapping paper sizes}
+\newlength{\baposter@swappapersizes}
+\setlength{\baposter@swappapersizes}{\baposter@finalpaperwidth}
+\setlength{\baposter@finalpaperwidth}{\baposter@finalpaperheight}
+\setlength{\baposter@finalpaperheight}{\baposter@swappapersizes}
+\fi
+
+\setlength{\baposter@basepaperwidth} {\baposter@fontscale\baposter@finalpaperwidth }
+\setlength{\baposter@basepaperheight}{\baposter@fontscale\baposter@finalpaperheight}
+\setlength{\baposter@basemargin}     {\baposter@fontscale\baposter@finalmargin}
+\newlength{\baposter@basemarginright}
+\setlength{\baposter@basemarginright}{\baposter@basemargin}
+\addtolength{\baposter@basemarginright}{-\baposter@fontscale\baposter@movebody}
+\newlength{\baposter@basemarginleft}
+\setlength{\baposter@basemarginleft}{\baposter@basemargin}
+\addtolength{\baposter@basemarginleft}{\baposter@fontscale\baposter@movebody}
 
-  \setlength{\baposter@basepaperwidth} {\baposter@fontscale\baposter@finalpaperwidth }
-  \setlength{\baposter@basepaperheight}{\baposter@fontscale\baposter@finalpaperheight}
-  \setlength{\baposter@basemargin}     {\baposter@fontscale\baposter@finalmargin}
-  \newlength{\baposter@basemarginright}
-  \setlength{\baposter@basemarginright}{\baposter@basemargin}
-  \addtolength{\baposter@basemarginright}{-\baposter@fontscale\baposter@movebody}
-  \newlength{\baposter@basemarginleft}
-  \setlength{\baposter@basemarginleft}{\baposter@basemargin}
-  \addtolength{\baposter@basemarginleft}{\baposter@fontscale\baposter@movebody}
-
-\typeout{Paperwidth=\the\baposter@finalpaperwidth}
-\typeout{Paperheight=\the\baposter@finalpaperheight}
-\typeout{BasePaperwidth=\the\baposter@basepaperwidth}
-\typeout{BasePaperheight=\the\baposter@basepaperheight}
+\debug{Paperwidth=\the\baposter@finalpaperwidth}
+\debug{Paperheight=\the\baposter@finalpaperheight}
+\debug{BasePaperwidth=\the\baposter@basepaperwidth}
+\debug{BasePaperheight=\the\baposter@basepaperheight}
 \usepackage[
    paperwidth=\baposter@basepaperwidth,
    paperheight=\baposter@basepaperheight,
@@ -187,29 +232,152 @@
    bmargin=\baposter@basemargin,
    lmargin=\baposter@basemarginleft,
    rmargin=\baposter@basemarginright,
-   showframe=\baposter@showframe,portrait]{geometry} % The portrait switch is necessary to override the double swapping which would otherwise happen in landscape mode
+   portrait]{geometry} % The portrait switch is necessary to override the double swapping which would otherwise happen in landscape mode
 
 \usepackage{pgfpages}
 \pgfpagesuselayout{resize to}[physical paper width=\baposter@finalpaperwidth,physical paper height=\baposter@finalpaperheight]
 
+
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%  Default functions for borders/backgrounds
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% New Version, with specified size
+
+%% These functions will all be redefined from the actual option values. In
+%% particular, they will be set to \baposter@optionname@optionvalue, which
+%% should do the actual work / setting for that particular optionvalue.
+
+\newcommand{\baposterPosterDrawBackground}[2]{} % Draw poster background
+
+\newcommand{\baposterBoxGetShape}{}             % Returns path of text box shape
+\newcommand{\baposterBoxDrawBackground}[2]{}    % Draw bg of boxes
+\newcommand{\baposterBoxDrawBorder}[1]{}        % Draw border of individual boxes
+
+\newcommand{\baposterHeaderGetShape}{}          % Returns path of text box shape
+\newcommand{\baposterHeaderSetShade}[3]{}       % Set bg style for box headers
+\newcommand{\baposterHeaderDrawBackground}[3]{} % Draw background of box header
+\newcommand{\baposterHeaderDrawBorder}[1]{}     % Draw border of box header
+\newcommand{\baposterHeaderDrawText}[1]{}       % Draw text inside box header
+
+\newcommand{\@@previousbox}{notset}             % stores the previously processed box for below=auto
+
+
+
+% Function to set a user-defined background
+\newcommand{\baposter@backgroundCmd}{\error{No background command defined. Use \background{...} to define background}}
+\newcommand{\background}[1]{\renewcommand{\baposter@backgroundCmd}{#1}}
+
+
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% New Version, with specified size
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 % TODO: Use choose-keys
-\typeout{Keys}
-\define@cmdkey[ba]{poster}[baposter@]{grid}                  [no]          {}
-\define@cmdkey[ba]{poster}[baposter@]{eyecatcher}            [yes]         {}
+\debug{Keys}
+
+%% Store all poster options in variables of the form \baposter@option
+%% choose-keys also store the index in \baposter@optionnr
+%% choose-keys typically also assign a function
+\define@boolkey[ba]{poster}[baposter@]{grid}                 [false]       {}
+\define@boolkey[ba]{poster}[baposter@]{eyecatcher}           [true]        {}
 \define@cmdkey[ba]{poster}[baposter@]{columns}               [{}]          {}
-\define@cmdkey[ba]{poster}[baposter@]{textborder}            [faded]       {}
-\define@cmdkey[ba]{poster}[baposter@]{headerborder}          [none]        {}
-\define@cmdkey[ba]{poster}[baposter@]{headershape}           [roundedright]{}
 \define@cmdkey[ba]{poster}[baposter@]{colspacing}            [1em]         {}
+\define@cmdkey[ba]{poster}[baposter@]{cornerradius}          [1em]         {}
+\define@cmdkey[ba]{poster}[baposter@]{boxheaderheight}       [2em]         {}
+\define@cmdkey[ba]{poster}[baposter@]{boxpadding}            [0.5em]       {}
 \define@cmdkey[ba]{poster}[baposter@]{headerheight}          [0.1\textheight]{}
-\define@cmdkey[ba]{poster}[baposter@]{headershade}           [shade-lr]    {}
-\define@cmdkey[ba]{poster}[baposter@]{boxshade}              [none]        {}
+
+% background can be one of: shadeLR, shadeTB, plain, user, none
+\define@choicekey*+[ba]{poster}{background}%
+    [\baposter@background\baposter@backgroundnr]%
+    {shadeLR, shadeTB, plain, user, none} [plain] {%
+  \debug{Poster background: \baposter@background}
+  \renewcommand{\baposterPosterDrawBackground}[2]{
+      \csname baposter@background@\baposter@background\endcsname{##1}{##2}}
+}{
+  \PackageWarning{baposter}{Unknown background `\baposter@background' (use
+      shadeLR, shadeTB, plain, none, or user). If user is used, you also
+      have to define \background{...}.}
+  \renewcommand{\baposterPosterDrawBackground}[2]{\baposter@background@none{##1}{##2}}
+}
+
+% textborder can be one of: none, bars, coils, triangles, rectangle, rounded,
+% roundedleft, roundedsmall, faded; UNIMPLEMENTED: roundedright
+\edef\baposter@textborder@validvalues{none,bars,coils,triangles,rectangle,rounded,roundedleft,roundedsmall,faded}
+\define@choicekey*+[ba]{poster}{textborder}%
+    [\baposter@textborder\baposter@textbordernr]%
+    {none,bars,coils,triangles,rectangle,rounded,roundedleft,roundedright,roundedsmall,faded} [rectangle] {%
+  \debug{Text border: \baposter@textborder}
+  \renewcommand{\baposterBoxGetShape}{
+      \csname baposter@boxshape@\baposter@textborder\endcsname}
+  \renewcommand{\baposterBoxDrawBorder}[1]{
+      \csname baposter@drawboxborder@\baposter@textborder\endcsname{##1}}
+}{
+  \PackageWarning{baposter}{Unknown text-border style `\baposter@textborder'.
+      Edit your file to choose a valid option (\baposter@textborder@validvalues).}
+  \renewcommand{\baposterBoxGetShape}{\baposter@boxshape@rectangle}
+  \renewcommand{\baposterBoxDrawBorder}[1]{\baposter@drawboxborder@rectangle{##1}}
+}
+
+% boxshade can be one of: shadeLR, shadeTB, plain, none
+\define@choicekey*+[ba]{poster}{boxshade}%
+    [\baposter@boxshade\baposter@boxshadenr]%
+    {shadelr,shadetb,plain,none} [none] {%
+  \debug{Box shade: \baposter@boxshade}
+  \renewcommand{\baposterBoxDrawBackground}[2]{
+      \csname baposter@drawboxbackground@\baposter@boxshade\endcsname{##1}{##2}}
+}{
+  \PackageWarning{baposter}{Unknown boxshade style `\baposter@boxshade'.
+      Edit your file to choose a valid option.}
+  \renewcommand{\baposterBoxDrawBackground}[2]{\baposter@drawboxbackground@none{##1}{##2}}
+}
+
+% headershade can be one of: shade-lr, shade-tb, shade-tb-inverse, plain
+\define@choicekey*+[ba]{poster}{headershade}%
+    [\baposter@headershade\baposter@headershadenr]%
+    {shadelr, shadetb, shadetbinverse, plain} [shadelr] {%
+  \debug{Box shade: \baposter@headershade}
+  \renewcommand{\baposterHeaderSetShade}[3]{
+      \csname baposter@headershade@\baposter@headershade\endcsname{##1}{##2}{##3}}
+}{
+  \PackageWarning{baposter}{Unknown headershade style `\baposter@headershade'.
+      Edit your file to choose a valid option.}
+  \renewcommand{\baposterHeaderSetShade}[3]{\baposter@headershade@none{##1}{##2}{##3}}
+}
+
+% headershape can be one of: rectangle, rounded, smallrounded, roundedleft, roundedright
+\define@choicekey*+[ba]{poster}{headershape}%
+    [\baposter@headershape\baposter@headershapenr]%
+    {rectangle,rounded,smallrounded,roundedleft,roundedright} [roundedright] {%
+  \debug{Header shape: \baposter@headershape}
+  \renewcommand{\baposterHeaderGetShape}{
+      \csname baposter@headershape@\baposter@headershape\endcsname}
+  \renewcommand{\baposterHeaderDrawText}[1]{
+      \csname baposter@headerdrawtext@\baposter@headershape\endcsname{##1}}
+  \renewcommand{\baposterHeaderDrawBorder}[1]{
+      \csname baposter@headerdrawborder@\baposter@headershape\endcsname{##1}}
+}{
+  \PackageWarning{baposter}{Unknown headershape style `\baposter@headershape'.
+      Edit your file to choose a valid option.}
+  \renewcommand{\baposterHeaderGetShape}{\baposter@headershape@rectangle}
+  \renewcommand{\baposterHeaderDrawText}[1]{\baposter@headerdrawtext@rectangle{##1}}
+  \renewcommand{\baposterHeaderDrawBorder}[1]{\baposter@headerdrawborder@rectangle{##1}}
+}
+
+% headerborder can be one of: open, closed, none
+\define@choicekey*+[ba]{poster}{headerborder}%
+    [\baposter@headerborder\baposter@headerbordernr]%
+    {open,closed,none} [open] {%
+  \debug{Header border: \baposter@headerborder}
+%   \renewcommand{\baposterHeaderBorder}{
+%       \csname baposter@headerborder@\baposter@headerborder\endcsname}
+}{
+  \PackageWarning{baposter}{Unknown headerborder style `\baposter@headerborder'.
+      Edit your file to choose a valid option.}
+%   \renewcommand{\baposterHeaderBorder}{\baposter@headerborder@rectangle}
+}
+
 
 \definecolor{baposter@silver}{cmyk}{0,0,0,0.7}
 \define@cmdkey[ba]{poster}[baposter@]{color}                 [orange]      {}
@@ -222,8 +390,6 @@
 \define@cmdkey[ba]{poster}[baposter@]{headerFontColor}       [black]       {}
 \define@cmdkey[ba]{poster}[baposter@]{boxColorOne}           [magenta]     {}
 \define@cmdkey[ba]{poster}[baposter@]{boxColorTwo}           [cyan]        {}
-
-\define@cmdkey[ba]{poster}[baposter@]{background}            [plain]       {}
 \define@cmdkey[ba]{poster}[baposter@]{headerfont}            [\sc\Large]   {}
 \define@cmdkey[ba]{poster}[baposter@]{textfont}              [{}]          {}
 
@@ -239,14 +405,11 @@
 \define@cmdkey[ba]{posterbox}[baposter@box@]{height} [auto]  {}
 \define@cmdkey[ba]{posterbox}[baposter@box@]{name}   [noname]{}
 
-\newcommand{\baposter@backgroundCmd}{\error{No background command defined. Use \background{...} to define background}}
-\newcommand{\background}[1]{\renewcommand{\baposter@backgroundCmd}{#1}}
-
 \presetkeys[ba]{poster}{
   % Debug grid
-  grid=no,
+  grid=false,
   % Is there an eyecatcher image
-  eyecatcher=yes,
+  eyecatcher=true,
   columns={},
   % Colours
   bgColorOne=baposter@silver,
@@ -259,14 +422,20 @@
   boxColorTwo=cyan,
   % Style
   headerborder=none,
+  headershape=rectangle,
   colspacing=1em,
   headerheight=0.1\textheight,
-  background=shade-lr,
-  headershade=shade-lr,
+  background=shadeLR,
+  headershade=shadeLR,
   boxshade=none,
   headerfont=\sc\Large,% or headerfont=\color{white}\textsf\textbf
   textfont={},
-  linewidth=2pt
+  textborder=faded,
+  linewidth=2pt,
+  %
+  cornerradius=1em,
+  boxheaderheight=2em,
+  boxpadding=0.5em,
 }{}
 \presetkeys[ba]{posterbox}{
   % Position
@@ -279,17 +448,249 @@
   name=noname,
 }{}
 
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Background options and functions (one function for each possible value)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newcommand{\baposter@background@shadelr}[2]{
+  \debug{BAPOSTER: Using shade left right background.}
+  \begin{tikzpicture}[remember picture,overlay]%
+    \shade [shading=axis,right color=#1,left color=#2] (current page.north west)
+           rectangle(current page.south east);
+  \end{tikzpicture}%
+}
+\newcommand{\baposter@background@shadetb}[2]{
+  \debug{BAPOSTER: Using shade top to bottom background.}
+  \begin{tikzpicture}[remember picture,overlay]%
+    \shade [shading=axis,top color=#1,bottom color=#2] (current page.north west)
+           rectangle(current page.south east);
+  \end{tikzpicture}%
+}
+\newcommand{\baposter@background@plain}[2]{
+  \debug{BAPOSTER: Using plain background.}
+  \begin{tikzpicture}[remember picture,overlay]%
+    \fill [fill=#1] (current page.north west) rectangle(current page.south east);
+  \end{tikzpicture}%
+}
+\newcommand{\baposter@background@user}[2]{
+  \debug{BAPOSTER: Using user background.}
+  \baposter@backgroundCmd%
+}
+\newcommand{\baposter@background@none}[2]{
+  \debug{BAPOSTER: Using no background.}
+}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Return shape path of text box (depending on the box shape)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newcommand{\baposter@boxshape@none}{\baposter@boxshape@rectangle}
+\newcommand{\baposter@boxshape@bars}{
+  (\baposter@box@name tnw) -- (\baposter@box@name sw) %
+  (\baposter@box@name se) -- (\baposter@box@name tne)
+}
+\newcommand{\baposter@boxshape@coils}{\baposter@boxshape@bars}
+\newcommand{\baposter@boxshape@triangles}{\baposter@boxshape@bars}
+\newcommand{\baposter@boxshape@rectangle}{
+  (\baposter@box@name tnw) -- (\baposter@box@name sw) -- %
+  (\baposter@box@name se) -- (\baposter@box@name tne)%
+}
+\newcommand{\baposter@boxshape@faded}{\baposter@boxshape@rectangle}
+\newcommand{\baposter@boxshape@rounded}{
+  [rc] \baposter@boxshape@rectangle%
+}
+\newcommand{\baposter@boxshape@roundedsmall}{
+  [src] \baposter@boxshape@rectangle
+}
+\newcommand{\baposter@boxshape@roundedleft}{
+  (\baposter@box@name tnw) {[rc]-- (\baposter@box@name sw)} -- %
+  (\baposter@box@name se) -- (\baposter@box@name tne)%
+}
+\newcommand{\baposter@boxshape@roundedright}{
+  (\baposter@box@name tnw) -- (\baposter@box@name sw) {[rc]-- %
+  (\baposter@box@name se)} -- (\baposter@box@name tne)%
+}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Draw box background (one function for each possible value)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% These functions take no arguments
+\newcommand{\baposter@drawboxbackground@none}[2]{
+  \tikzstyle{box colors}=[]
+}
+\newcommand{\baposter@drawboxbackground@plain}[2]{
+  \tikzstyle{box colors}=[fill=#1]
+  \fill[box colors] \baposterBoxGetShape;
+}
+\newcommand{\baposter@drawboxbackground@shadelr}[2]{
+  \tikzstyle{box colors}=[shading=axis, left color=#1, right color=#2]%
+  \fill[box colors] \baposterBoxGetShape;
+}
+\newcommand{\baposter@drawboxbackground@shadetb}[2]{
+  \tikzstyle{box colors}=[shading=axis, top color=#1, bottom color=#2]%
+  \fill[box colors] \baposterBoxGetShape;
+}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Draw box border
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% These functions take two arguments: borderColor
+\newcommand{\baposter@drawboxborder@none}[1]{}
+\newcommand{\baposter@drawboxborder@bars}[1]{
+  \draw[color=#1] \baposterBoxGetShape;%
+}
+\newcommand{\baposter@drawboxborder@coils}[1]{
+  \draw[color=#1,segment amplitude=0.35em,segment length=0.4em,snake=coil] \baposterBoxGetShape;%
+}
+\newcommand{\baposter@drawboxborder@triangles}[1]{
+  \draw[color=#1,segment amplitude=0.2em,segment length=0.4em,snake=triangles] \baposterBoxGetShape;%
+}
+\newcommand{\baposter@drawboxborder@rectangle}[1]{
+  \draw[color=#1] \baposterBoxGetShape;%
+}
+\newcommand{\baposter@drawboxborder@rounded}[1]{
+  \draw[color=#1] \baposterBoxGetShape;%
+}
+\newcommand{\baposter@drawboxborder@roundedleft}[1]{
+  \draw[color=#1] \baposterBoxGetShape;%
+}
+\newcommand{\baposter@drawboxborder@faded}[1]{
+  \draw [color=#1,path fading=south] \baposterBoxGetShape;%
+}
+\newcommand{\baposter@drawboxborder@roundedsmall}[1]{
+  \draw[color=#1] \baposterBoxGetShape;%
+}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Return shape path of text box (depending on the box shape)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% These functions take no arguments
+% TODO: For headerborder==none, use (\baposter@box@name outer tnw) instead!
+\newcommand{\baposter@headershape@rectangle}{%
+  (\baposter@box@name tnw) -- (\baposter@box@name nw) -- %
+  (\baposter@box@name ne) -- (\baposter@box@name tne)%
+}
+\newcommand{\baposter@headershape@smallrounded}{%
+  (\baposter@box@name tnw) {[src] -- (\baposter@box@name nw) -- %
+  (\baposter@box@name ne)} -- (\baposter@box@name tne)%
+}
+\newcommand{\baposter@headershape@roundedright}{%
+  (\baposter@box@name tnw) -- (\baposter@box@name nw) {[rc] -- %
+  (\baposter@box@name ne)} -- (\baposter@box@name tne)%
+}
+\newcommand{\baposter@headershape@roundedleft}{%
+  (\baposter@box@name tnw) {[rc]-- (\baposter@box@name nw)} -- %
+  (\baposter@box@name ne) -- (\baposter@box@name tne)%
+}
+\newcommand{\baposter@headershape@rounded}{%
+  (\baposter@box@name tnw) {[rc] -- (\baposter@box@name nw) -- %
+  (\baposter@box@name ne) } -- (\baposter@box@name tne)%
+}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Header text drawing (one function for each possible value of headershape)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% These functions take one argument: the header text
+\newcommand{\baposter@headerdrawtext@rectangle}[1]{
+  \path (\baposter@box@name nw) +(0em,-0.5\baposter@@boxheaderheight) node[anchor=west,inner sep=0.4em] {#1};%
+}
+\newcommand{\baposter@headerdrawtext@smallrounded}[1]{
+  \path (\baposter@box@name nw) +(0.5\boxwidth,-0.5\baposter@@boxheaderheight) node[anchor=center] {#1};%
+}
+\newcommand{\baposter@headerdrawtext@roundedright}[1]{
+  \path (\baposter@box@name nw) +(0em,-0.5\baposter@@boxheaderheight)%
+        node[anchor=west,inner sep=0.4em,text depth=0.0em] {#1};%
+}
+\newcommand{\baposter@headerdrawtext@roundedleft}[1]{
+  \path (\baposter@box@name nw) +(0em,-0.5\baposter@@boxheaderheight)%
+        node[anchor=west,inner sep=0.4em] {#1};%
+}
+\newcommand{\baposter@headerdrawtext@rounded}[1]{
+    \path (\baposter@box@name nw) +(0.5\boxwidth,-0.5\baposter@@boxheaderheight) node[anchor=center] {#1};%
+}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Header shade options and functions (one function for each possible value)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% These functions take two arguments: headerColorOne, headerColorTwo and borderColor
+\newcommand{\baposter@headershade@shadelr}[3]{
+    \debug{Header-Shade: Shade Left - Right}
+    \tikzstyle{header colors}=[%
+      color=#3,%
+      shading=axis,%
+      left color=#1,%
+      right color=#2%
+    ]%
+}
+\newcommand{\baposter@headershade@shadetb}[3]{
+    \debug{Header-Shade: Shade Top - Bottom}
+    \tikzstyle{header colors}=[%
+      color=#3,%
+      shading=axis,%
+      top color=#1,%
+      bottom color=#2%
+    ]%
+}
+\newcommand{\baposter@headershade@shadetbinverse}[3]{
+    \tikzstyle{header colors}=[%
+      top color=#1!75!#2,%
+      bottom color=#2!100!#1,%
+      shading angle=20%
+    ]%
+    \colorlet{baposterHeaderFontColor}{white}%
+}
+\newcommand{\baposter@headershade@plain}[3]{
+    \debug{Header-Shade: Plain}
+    \tikzstyle{header colors}=[%
+      color=#3,%
+      fill=#1%
+    ]%
+}
+\newcommand{\baposter@headershade@none}[3]{
+    \debug{Header-Shade: none}
+    \tikzstyle{header colors}=[]
+}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Header shade options and functions (one function for each possible value)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% These functions take no arguments
+% TODO: Drawing routines for header border & background
+
+
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%% The main poster environment
 %%% \begin{baposter}{settings}{Eye Catcher}{Title}{Author}{University Logo}
 %%%-----------------------------------------------------------------------------
 %%% The settings are
-%%%   - grid=yes,[no]:    Show grid to help with alignment
+%%%   - grid=true,[false]:Show grid to help with alignment
 %%%   - colspacing=0.7em: Column spacing
 %%%   - columns=4:        number of columns (default 4 in landscape and 3 in portrait format) (maximum number is 6)
 %%%   - color=[orange]:   xcolor color definition used as the main color of the poster
 %%%   - colortwo=[white]: The other color for gradient based layouts
-%%%   - textborder=none,bars,coils,triangles,rectangle,rounded,small-rounded,roundedleft,roundedright,[faded]
+%%%   - textborder=none,bars,coils,triangles,rectangle,rounded,roundedsmall,roundedleft,roundedright,[faded]
 %%%                       The style of the box around the text area
 %%%   - headerborder=none,closed,open
 %%%                       No extra border around box header, full border around box header or border that is open below.
@@ -298,9 +699,15 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \newenvironment{poster}[5]{%
   \thispagestyle{empty}% Suppress Page Number
-  \typeout{Poster Starts}%
+  \debug{Poster Starts}%
+  % This setkeys call parses all provided options and depending on the option
+  % value, assigns different handler functions to the \baposter(Box|Header)*
+  % functions. Once that is done, we don't have to care about particular
+  % values for border, shading, etc. All we have to do is call the 
+  % handler functions and let them do their job.
   \setkeys[ba]{poster}{#1}%
 %
+  % TODO: Move all those assignments to the key macros!
   % Parse Keys%
   \colorlet{bgColorOne}{\baposter@bgColorOne}
   \colorlet{bgColorTwo}{\baposter@bgColorTwo}
@@ -315,80 +722,39 @@
   \setlength{\headerheight}{\baposter@headerheight}%
   \setlength{\colheight}{\textheight-\baposter@headerheight}%
 %
-  \typeout{Format}%
-  \iflandscape%
-    \ifthenelse{\equal{\baposter@columns}{}}{\renewcommand{\baposter@columns}{4}}{}
-  \else%
-    \ifthenelse{\equal{\baposter@columns}{}}{\renewcommand{\baposter@columns}{3}}{}
-  \fi%
+  \setlength{\baposter@@cornerradius}{\baposter@cornerradius}%
+  \setlength{\baposter@@boxheaderheight}{\baposter@boxheaderheight}%
+  \setlength{\baposter@@boxpadding}{\baposter@boxpadding}%
+
+  \renewcommand{\@@previousbox}{notset}
+
+  \debug{Format}%
+  % Set default for columns if unset (4 for landscape, 3 for portrait)
+  \ifthenelse{\equal{\baposter@columns}{}}{%
+    \renewcommand{\baposter@columns}{\if@landscape\relax4\else3\fi}%
+  }{}
 %
-  \typeout{Columns: \baposter@columns}%
+  \debug{Columns: \baposter@columns}%
   \setlength{\baposter@@colspacing}{\baposter@colspacing}%
-  \typeout{1}%
   \setlength{\colwidth}{\textwidth}%
-  \typeout{2}%
-  \addtolength{\colwidth}{-\baposter@columns\baposter@@colspacing}\addtolength{\colwidth}{\baposter@@colspacing}%
-  \typeout{3}%
-  \ifthenelse{\equal{\baposter@columns}{1}}{
+  \addtolength{\colwidth}{\baposter@@colspacing*(1-\baposter@columns)}%
+  \ifcase\baposter@columns\relax
+    \error{You need to have at least one column!}
+  \or % 1
     \setlength{\colwidth}{\colwidth}%
-  }{
-    \ifthenelse{\equal{\baposter@columns}{2}}{
-      \setlength{\colwidth}{0.5\colwidth}%
-    }{
-      \ifthenelse{\equal{\baposter@columns}{3}}{
-        \setlength{\colwidth}{0.3333333333333\colwidth}%
-      }{
-        \ifthenelse{\equal{\baposter@columns}{4}}{
-          \setlength{\colwidth}{0.25\colwidth}%
-        }{
-          \ifthenelse{\equal{\baposter@columns}{5}}{
-            \setlength{\colwidth}{0.2\colwidth}%
-          }{
-            \ifthenelse{\equal{\baposter@columns}{6}}{
-              \setlength{\colwidth}{0.16666666666\colwidth}%
-            }{
-              \error{You do not want so many columns}
-            }
-          }
-        }
-      }
-    }
-  }
-%
-  % Background image%
-  \newcommand{\baposterShadedBG}{%
-    \ifthenelse{\equal{\baposter@background}{shade-lr}}{%
-      \begin{tikzpicture}[remember picture,overlay]%
-        \shade [shading=axis,right color=bgColorOne,left color=bgColorTwo] (current page.north west) rectangle(current page.south east);
-        \typeout{BAPOSTER: Using shade left right background.}
-      \end{tikzpicture}%
-    }{%
-      \ifthenelse{\equal{\baposter@background}{shade-tb}}{%
-        \typeout{BAPOSTER: Using shade top to bottom background.}
-        \begin{tikzpicture}[remember picture,overlay]%
-          \shade [shading=axis,top color=bgColorOne,bottom color=bgColorTwo] (current page.north west) rectangle(current page.south east);
-        \end{tikzpicture}%
-      }{%
-        \ifthenelse{\equal{\baposter@background}{plain}}{%
-          \typeout{BAPOSTER: Using plain background.}
-          \begin{tikzpicture}[remember picture,overlay]%
-            \fill [fill=bgColorOne] (current page.north west) rectangle(current page.south east);
-          \end{tikzpicture}%
-        }{%
-          \ifthenelse{\equal{\baposter@background}{user}}{%
-            \typeout{BAPOSTER: Using user background.}
-            \baposter@backgroundCmd%
-          }{%
-            \ifthenelse{\equal{\baposter@background}{none}}{%
-              \typeout{BAPOSTER: Using no background.}
-            }{%
-              \error{Unknown background, use shade-lr, shade-tb, plain, none, or user. If user is used, you also have to define \background{...} }%
-            }%
-          }%
-        }%
-      }%
-    }%
-  }%
+  \or % 2
+    \setlength{\colwidth}{0.5\colwidth}%
+  \or % 3
+    \setlength{\colwidth}{0.3333333333333\colwidth}%
+  \or % 4
+    \setlength{\colwidth}{0.25\colwidth}%
+  \or % 5
+    \setlength{\colwidth}{0.2\colwidth}%
+  \or % 6
+    \setlength{\colwidth}{0.16666666666\colwidth}%
+  \else % >6
+    \error{You do not want so many columns}
+  \fi
 %
   \newcommand{\baposter@reference}{north west}%
 %
@@ -412,33 +778,45 @@
   % height= <size in percent of column height>,[auto]%
   % name=   [noname]%
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+  % Backward-compatibility definition (\headerbox command uses posterbox env):
   \newcommand{\headerbox}[3]{%
-    \typeout{##2}%
-    \setkeys[ba]{posterbox}{##2}%
+    \begin{posterbox}[##2]{##1}
+      ##3
+    \end{posterbox}
+  }
+
+  \newenvironment{posterbox}[2][]{%
+    \debug{Poster box options: ##1}%
+    \setkeys[ba]{posterbox}{##1}%
 %
+    \def\baposter@box@title{##2}
 %
     %% The columns is always given absolute
-    % boxstartx = \baposter@box@column * colwidth + (\baposter@box@column-1) * baposter@@colspacing
-    \setlength{\boxstartx}{\baposter@box@column\colwidth}%
-    \addtolength{\boxstartx}{\baposter@box@column\baposter@@colspacing}%
+    % boxstartx = column * colwidth + column * colspacing
+    \setlength{\boxstartx}{(\colwidth+\baposter@@colspacing)*\baposter@box@column}%
 %
     %% The width is gvien absolute
-    % Box Width = \baposter@box@span * colwidth + (\baposter@box@span-1) * baposter@@colspacing
+    % Box Width = span * colwidth + (span-1) * colspacing
     \setlength{\boxwidth}{\baposter@box@span\colwidth} %
-    \addtolength{\boxwidth}{\baposter@box@span\baposter@@colspacing}%
-    \addtolength{\boxwidth}{-\baposter@@colspacing}%
+    \addtolength{\boxwidth}{\baposter@@colspacing*(\baposter@box@span-1)}%
 %
     %% Measure the content of the box%
-    \setbox\baposter@content=\hbox{%
+    \setbox\baposter@content=\hbox\bgroup%
       \begin{pgfinterruptpicture}%
-        \begin{minipage}[t]{\boxwidth-1em}%
-          \baposter@textfont{##3}%
+        \begin{minipage}[t]{\boxwidth-\baposter@@boxpadding*2}%
+          \baposter@textfont\bgroup%
+  }% End of posterbox preamble
+  %%% HERE COME THE ACTUAL CONTENTS OF THE HEADERBOX ENVIRONMENT
+  {% posterbox handling after contents (i.e. drawing everything)
+          \egroup%
         \end{minipage}%
       \end{pgfinterruptpicture}%
-    }%
-    \setlength{\boxheight}{\ht\baposter@content}\addtolength{\boxheight}{\dp\baposter@content}%
-    \addtolength{\boxheight}{2em} % Header%
-    \addtolength{\boxheight}{1em} % Inner Sep%
+    \egroup%
+    \setlength{\boxheight}{\ht\baposter@content}%
+    \addtolength{\boxheight}{\dp\baposter@content}%
+    \addtolength{\boxheight}{\baposter@@boxheaderheight} % Header%
+    \addtolength{\boxheight}{2\baposter@@boxpadding} % Inner Sep
 %
     \ifthenelse{\equal{\baposter@box@height}{bottom}}{%
     }{\ifthenelse{\equal{\baposter@box@height}{auto}}{%
@@ -447,32 +825,41 @@
     }}%
 %
     %% Determine the box position%
-    \typeout{Setting Coordinates}%
-    \typeout{Upper Right}%
-    \typeout{\baposter@box@name}%
+    \debug{Setting Coordinates}%
+    \debug{Upper Right}%
+    \debug{\baposter@box@name}%
 %
     %%% Upper Right Corner%
+    % if below=auto, set it to the previous box
+    % TODO: We should generalize this to the previous box of the used column,
+    %       currently we use the previous box, which might be in a different column
+    \ifthenelse{\equal{\baposter@box@below}{auto}}{%
+        \edef\baposter@box@below{\@@previousbox}
+        \debug{Box \baposter@box@name  has below=auto, placing it below box \baposter@box@below.}
+    }{}
+    \xdef\@@previousbox{\baposter@box@name}
+
     \ifthenelse{\not\equal{\baposter@box@below}{notset} }{%
       %% Below%
-      \typeout{Below}%
+      \debug{Below}%
       \path[shape=coordinate] (\boxstartx,0pt |- \baposter@box@below se) ++(0pt,-\baposter@@colspacing) coordinate(\baposter@box@name nw);%
     }{%
       \ifthenelse{\not\equal{\baposter@box@aligned}{notset} }{%
         %% Aligned%
-        \typeout{Aligned: \baposter@box@aligned}%
+        \debug{Aligned: \baposter@box@aligned}%
         \path[shape=coordinate] (\boxstartx,0pt |- \baposter@box@aligned nw)                           coordinate(\baposter@box@name nw);%
       }{%
         %% Fixed%
-        \typeout{Fixed}%
+        \debug{Fixed}%
         \setlength{\boxstarty}{\baposter@box@row\colheight}%
         \path[shape=coordinate] (\boxstartx,\colheight-\boxstarty)                                                  coordinate(\baposter@box@name nw);%
     }}%
 %
     %% Lower Left Corner%
-    \typeout{Lower Left}%
+    \debug{Lower Left}%
     \ifthenelse{\equal{\baposter@box@above}{bottom}}{%
       %% Above = Bottom%
-      \typeout{Above bottom}%
+      \debug{Above bottom}%
       \ifthenelse{\equal{\baposter@box@below}{notset} \and \equal{\baposter@box@aligned}{notset}}{%
       \path[shape=coordinate] (\boxstartx,\boxheight)                                                              coordinate(\baposter@box@name nw);%
       }{}%
@@ -484,24 +871,24 @@
         \path[shape=coordinate] (\boxstartx+\boxwidth,0pt |- \baposter@box@above nw)  +(0pt,\baposter@@colspacing) coordinate(\baposter@box@name se);%
       }{%
         %% Above = notset%
-        \typeout{Above=not set}%
+        \debug{Above=not set}%
         \ifthenelse{\equal{\baposter@box@height}{bottom}}{%
           %% height=bottom%
-          \typeout{height=bottom}%
+          \debug{height=bottom}%
           \path[shape=coordinate] (\boxstartx+\boxwidth,0pt)                                                       coordinate(\baposter@box@name se);%
         }{ %% height=auto or fixed%
-          \typeout{height=auto or fixed}%
+          \debug{height=auto or fixed}%
           \path[shape=coordinate] (\baposter@box@name nw) ++(\boxwidth,-\boxheight)                                coordinate(\baposter@box@name se);%
 	  }}}}}%
 %
         %
     % Set coordinates relative to nw,se%
-    \typeout{Fixing Coordinates}%
+    \debug{Fixing Coordinates}%
     \path[shape=coordinate]%
-      (\baposter@box@name nw) +(0pt,-2em)                coordinate(\baposter@box@name tnw)%
+      (\baposter@box@name nw) +(0pt,-\baposter@@boxheaderheight)                coordinate(\baposter@box@name tnw)%
       (\baposter@box@name nw |- \baposter@box@name se)   coordinate(\baposter@box@name sw)%
       (\baposter@box@name se |- \baposter@box@name nw)   coordinate(\baposter@box@name ne)%
-      (\baposter@box@name ne) +(0pt,-2em)                coordinate(\baposter@box@name tne)%
+      (\baposter@box@name ne) +(0pt,-\baposter@@boxheaderheight)                coordinate(\baposter@box@name tne)%
 %
       (\baposter@box@name nw)  +(-0.025em,0pt)           coordinate(\baposter@box@name outer nw)%
       (\baposter@box@name tnw) +(-0.025em,0pt)           coordinate(\baposter@box@name outer tnw)%
@@ -511,276 +898,68 @@
       (\baposter@box@name tne) +( 0.025em,0pt)           coordinate(\baposter@box@name outer tne)%
       (\baposter@box@name se)  +( 0.025em,0pt)           coordinate(\baposter@box@name outer se);%
 %
-      \ifthenelse{\equal{\baposter@headershade}{shade-lr}}{%
-        \typeout{Header-Shade: Shade Left - Right}
-        \tikzstyle{header colors}=[%
-          color=borderColor,%
-          shading=axis,%
-          left color=headerColorOne,%
-          right color=headerColorTwo%
-          ]%
-      }{\ifthenelse{\equal{\baposter@headershade}{shade-tb}}{%
-        \typeout{Header-Shade: Shade Top - Bottom}
-        \tikzstyle{header colors}=[%
-          color=borderColor,%
-          shading=axis,%
-          top color=headerColorOne,%
-          bottom color=headerColorTwo%
-          ]%
-      }{\ifthenelse{\equal{\baposter@headershade}{shade-tb-inverse}}{%
-        \tikzstyle{header colors}=[%
-          top color=headerColorOne!75!headerColorTwo,%
-          bottom color=headerColorTwo!100!headerColorOne,%
-          shading angle=20%
-          ]%
-          \colorlet{baposterHeaderFontColor}{white}%
-      }{\ifthenelse{\equal{\baposter@headershade}{plain}}{%
-        \typeout{Header-Shade: Plain}
-        \tikzstyle{header colors}=[%
-          color=borderColor,%
-          fill=headerColorOne%
-          ]%
-      }{%
-        \typeout{Header-Shade: Unknown Style: \baposter@headershade}
-        \PackageError{baposter.cls}{Unknown header shade style \baposter@headershade}{Edit your file to choose a valid option}{}%
-      }}}}%
-      \typeout{Box-Shade: \baposter@boxshade}
-      \ifthenelse{\equal{\baposter@boxshade}{shade-lr}}{%
-        \tikzstyle{box colors}=[%
-          shading=axis,%
-          left color=boxColorOne,%
-          right color=boxColorTwo%
-          ]%
-      }{%
-        \ifthenelse{\equal{\baposter@boxshade}{shade-tb}}{%
-          \tikzstyle{box colors}=[%
-            shading=axis,%
-            top color=boxColorOne,%
-            bottom color=boxColorTwo%
-            ]%
-        }{%
-          \ifthenelse{\equal{\baposter@boxshade}{plain}}{%
-            \tikzstyle{box colors}=[%
-              fill=boxColorOne%
-              ]%
-          }{%
-            \ifthenelse{\equal{\baposter@boxshade}{none}}{%
-              \tikzstyle{box colors}=[]%
-            }{%
-              \PackageError{baposter.cls}{Unknown box shade style \baposter@boxshade}{Edit your file to choose a valid option}{}%
-            }%
-          }%
-        }%
-      }%
-      \tikzstyle{rc}=[rounded corners=2em];%
+      %% Setting the bg colors of the box header
+      \baposterHeaderSetShade{headerColorOne}{headerColorTwo}{borderColor}
+%
+      \tikzstyle{rc}=[rounded corners=\baposter@@cornerradius];%
       \tikzstyle{src}=[rounded corners=0.5em];%
 %
+
+    %% Now that everything is set up, draw the actual box, with bg and header
     \begin{scope}[line width=\baposter@linewidth]
-      \typeout{Header}%
-      \typeout{Header-Shape: \baposter@headershape}%
       %% Header%
-      \ifthenelse  {\equal{\baposter@headershape}{rectangle}}   {%
-      %%%
-        \ifthenelse{\equal{\baposter@headerborder}{open}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \filldraw  [style=header colors] (\baposter@box@name tnw)                 -- (\baposter@box@name nw)         -- (\baposter@box@name ne)       -- (\baposter@box@name tne);%
-          }{
-            \shadedraw [style=header colors] (\baposter@box@name tnw)                 -- (\baposter@box@name nw)         -- (\baposter@box@name ne)       -- (\baposter@box@name tne);%
-          }
-        }{\ifthenelse{\equal{\baposter@headerborder}{closed}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \filldraw  [style=header colors] (\baposter@box@name tnw)                 -- (\baposter@box@name nw)         -- (\baposter@box@name ne)       -- (\baposter@box@name tne) -- cycle;%
-          }{
-            \shadedraw [style=header colors] (\baposter@box@name tnw)                 -- (\baposter@box@name nw)         -- (\baposter@box@name ne)       -- (\baposter@box@name tne) -- cycle;%
-          }
-        }{\ifthenelse{\equal{\baposter@headerborder}{none}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \fill      [style=header colors] (\baposter@box@name outer tnw)           -- (\baposter@box@name outer nw)   -- (\baposter@box@name outer ne) -- (\baposter@box@name outer tne) -- cycle;%
-          }{
-            \shade     [style=header colors] (\baposter@box@name outer tnw)           -- (\baposter@box@name outer nw)   -- (\baposter@box@name outer ne) -- (\baposter@box@name outer tne) -- cycle;%
-          }
-        }{\PackageError{baposter.cls}{Unknown header border \baposter@headerborder}{Edit your file to choose a valid option}}}}{}%
-        \path (\baposter@box@name nw) +(0em,-1em) node[anchor=west,inner sep=0.4em] {\color{headerFontColor}\baposter@headerfont{##1}};%
-      %%%
-      }{\ifthenelse{\equal{\baposter@headershape}{small-rounded}}     {%
-      %%%
-        \ifthenelse{\equal{\baposter@headerborder}{open}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \filldraw  [style=header colors] (\baposter@box@name tnw)       {[rc]     -- (\baposter@box@name nw)         -- (\baposter@box@name ne)      } -- (\baposter@box@name tne);%
-          }{
-            \shadedraw [style=header colors] (\baposter@box@name tnw)       {[rc]     -- (\baposter@box@name nw)         -- (\baposter@box@name ne)      } -- (\baposter@box@name tne);%
-          }
-        }{\ifthenelse{\equal{\baposter@headerborder}{closed}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \filledraw [style=header colors] (\baposter@box@name tnw)       {[rc]     -- (\baposter@box@name nw)         -- (\baposter@box@name ne)      } -- (\baposter@box@name tne) -- cycle;%
-          }{
-            \shadedraw [style=header colors] (\baposter@box@name tnw)       {[rc]     -- (\baposter@box@name nw)         -- (\baposter@box@name ne)      } -- (\baposter@box@name tne) -- cycle;%
-          }
-        }{\ifthenelse{\equal{\baposter@headerborder}{none}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \fill      [style=header colors] (\baposter@box@name outer tnw) {[rc]     -- (\baposter@box@name outer nw)   -- (\baposter@box@name outer ne)} -- (\baposter@box@name outer tne) -- cycle;%
-          }{
-            \shade     [style=header colors] (\baposter@box@name outer tnw) {[rc]     -- (\baposter@box@name outer nw)   -- (\baposter@box@name outer ne)} -- (\baposter@box@name outer tne) -- cycle;%
-          }
-        }{\PackageError{baposter.cls}{Unknown header border \baposter@headerborder}{Edit your file to choose a valid option}}}}{}%
-        \path (\baposter@box@name nw) +(0.5\boxwidth,-1em) node[anchor=center] {\color{headerFontColor}\baposter@headerfont{##1}};%
-      %%%
-      }{\ifthenelse{\equal{\baposter@headershape}{roundedright}}{%
-      %%%
-        \ifthenelse{\equal{\baposter@headerborder}{open}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \filldraw  [style=header colors] (\baposter@box@name tnw)                 -- (\baposter@box@name nw)       {[rc] -- (\baposter@box@name ne)      } -- (\baposter@box@name tne);%
-          }{
-            \shadedraw [style=header colors] (\baposter@box@name tnw)                 -- (\baposter@box@name nw)       {[rc] -- (\baposter@box@name ne)      } -- (\baposter@box@name tne);%
-          }
-        }{\ifthenelse{\equal{\baposter@headerborder}{closed}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \filldraw  [style=header colors] (\baposter@box@name tnw)                 -- (\baposter@box@name nw)       {[rc] -- (\baposter@box@name ne)      } -- (\baposter@box@name tne) -- cycle;%
-          }{
-            \shadedraw [style=header colors] (\baposter@box@name tnw)                 -- (\baposter@box@name nw)       {[rc] -- (\baposter@box@name ne)      } -- (\baposter@box@name tne) -- cycle;%
-          }
-        }{\ifthenelse{\equal{\baposter@headerborder}{none}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \fill      [style=header colors] (\baposter@box@name outer tnw)           -- (\baposter@box@name outer nw) {[rc] -- (\baposter@box@name outer ne)} -- (\baposter@box@name outer tne) -- cycle;%
-          }{
-            \shade     [style=header colors] (\baposter@box@name outer tnw)           -- (\baposter@box@name outer nw) {[rc] -- (\baposter@box@name outer ne)} -- (\baposter@box@name outer tne) -- cycle;%
-          }
-        }{\PackageError{baposter.cls}{Unknown header border \baposter@headerborder}{Edit your file to choose a valid option}}}}{}%
-        \path (\baposter@box@name nw) +(0em,-1em) node[anchor=west,inner sep=0.4em,text depth=0.0em] {\color{headerFontColor}\baposter@headerfont{##1}};%
-      %%%
-      }{\ifthenelse{\equal{\baposter@headershape}{roundedleft}}{%
-      %%%
-        \ifthenelse{\equal{\baposter@headerborder}{open}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \filldraw  [style=header colors,color=borderColor] (\baposter@box@name tnw)            {[rc]-- (\baposter@box@name nw)       }     -- (\baposter@box@name ne)       -- (\baposter@box@name tne);%
-          }{
-            \shadedraw [style=header colors,color=borderColor] (\baposter@box@name tnw)            {[rc]-- (\baposter@box@name nw)       }     -- (\baposter@box@name ne)       -- (\baposter@box@name tne);%
-          }
-        }{\ifthenelse{\equal{\baposter@headerborder}{closed}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \filldraw  [style=header colors,color=borderColor] (\baposter@box@name tnw)            {[rc]-- (\baposter@box@name nw)       }     -- (\baposter@box@name ne)       -- (\baposter@box@name tne) -- cycle;%
-          }{
-            \shadedraw [style=header colors,color=borderColor] (\baposter@box@name tnw)            {[rc]-- (\baposter@box@name nw)       }     -- (\baposter@box@name ne)       -- (\baposter@box@name tne) -- cycle;%
-          }
-        }{\ifthenelse{\equal{\baposter@headerborder}{none}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \fill      [style=header colors,color=borderColor] (\baposter@box@name outer tnw)      {[rc]-- (\baposter@box@name outer nw) }     -- (\baposter@box@name outer ne) -- (\baposter@box@name outer tne) -- cycle;%
-          }{
-            \shade     [style=header colors,color=borderColor] (\baposter@box@name outer tnw)      {[rc]-- (\baposter@box@name outer nw) }     -- (\baposter@box@name outer ne) -- (\baposter@box@name outer tne) -- cycle;%
-          }
-        }{\PackageError{baposter.cls}{Unknown header border \baposter@headerborder}{Edit your file to choose a valid option}}}}{}%
-        \path (\baposter@box@name nw) +(0em,-1em) node[anchor=west,inner sep=0.4em] {\color{headerFontColor}\baposter@headerfont{##1}};%
-      %%%
-      }{\ifthenelse{\equal{\baposter@headershape}{rounded}}     {%
-      %%%
-        \ifthenelse{\equal{\baposter@headerborder}{open}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \filldraw  [style=header colors] (\baposter@box@name tnw)       {[rc]     -- (\baposter@box@name nw)         -- (\baposter@box@name ne)      } -- (\baposter@box@name tne);%
-          }{
-            \shadedraw [style=header colors] (\baposter@box@name tnw)       {[rc]     -- (\baposter@box@name nw)         -- (\baposter@box@name ne)      } -- (\baposter@box@name tne);%
-          }
-        }{\ifthenelse{\equal{\baposter@headerborder}{closed}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \filldraw  [style=header colors] (\baposter@box@name tnw)       {[rc]     -- (\baposter@box@name nw)         -- (\baposter@box@name ne)      } -- (\baposter@box@name tne) -- cycle;%
-          }{
-            \shadedraw [style=header colors] (\baposter@box@name tnw)       {[rc]     -- (\baposter@box@name nw)         -- (\baposter@box@name ne)      } -- (\baposter@box@name tne) -- cycle;%
-          }
-        }{\ifthenelse{\equal{\baposter@headerborder}{none}}{%
-          \ifthenelse{\equal{\baposter@headershade}{plain}}{
-            \fill      [style=header colors] (\baposter@box@name outer tnw) {[rc]     -- (\baposter@box@name outer nw)   -- (\baposter@box@name outer ne)} -- (\baposter@box@name outer tne) -- cycle;%
-          }{
-            \shade     [style=header colors] (\baposter@box@name outer tnw) {[rc]     -- (\baposter@box@name outer nw)   -- (\baposter@box@name outer ne)} -- (\baposter@box@name outer tne) -- cycle;%
-          }
-        }{\PackageError{baposter.cls}{Unknown header border \baposter@headerborder}{Edit your file to choose a valid option}}}}{}%
-        \path (\baposter@box@name nw) +(0.5\boxwidth,-1em) node[anchor=center] {\color{headerFontColor}\baposter@headerfont{##1}};%
-      %%%
-      }{%
-        \typeout{Unknown header style \baposter@headershape}
-        \PackageError{baposter.cls}{Unknown header style \baposter@headershape}{Edit your file to choose a valid option}{}%
-      }}}}}%
-  %
-      \typeout{Sidebars}%
-      %% Sidebars%
-      \ifthenelse  {\equal{\baposter@textborder}{none}}    {%
-      }{\ifthenelse{\equal{\baposter@textborder}{bars}}{%
-        \begin{scope}[color=borderColor]%
-          \draw (\baposter@box@name tne) -- (\baposter@box@name se);%
-          \draw (\baposter@box@name tnw) -- (\baposter@box@name sw);%
-        \end{scope}%
-      }{\ifthenelse{\equal{\baposter@textborder}{coils}}{%
-        \begin{scope}[color=borderColor,segment amplitude=0.35em,segment length=0.4em,snake=coil]%
-          \draw (\baposter@box@name tne) -- (\baposter@box@name se);%
-          \draw (\baposter@box@name tnw) -- (\baposter@box@name sw);%
-        \end{scope}%
-      }{\ifthenelse{\equal{\baposter@textborder}{triangles}}{%
-        \begin{scope}[color=borderColor,segment amplitude=0.2em,segment length=0.4em,snake=triangles]%
-          \draw [snake=triangles] (\baposter@box@name tne) -- (\baposter@box@name se);%
-          \draw [snake=triangles] (\baposter@box@name tnw) -- (\baposter@box@name sw);%
-        \end{scope}%
-      }{\ifthenelse{\equal{\baposter@textborder}{rectangle}}{%
-        \begin{scope}[color=borderColor]%
-        \ifthenelse{\equal{\baposter@boxshade}{none}}{%
+      \debug{Header}%
+      \debug{Header-Shape: \baposter@headershape, header-border: \baposter@headerborder (\baposter@headerbordernr)}%
+      % TODO: Also turn this last ifcase construct into a handler function
+      %       We only need to determine (fill|shade)(draw|)...
+%       \baposterHeaderDrawBackground{bgColorOne}{bgColorTwo}{borderColor}
+%       \baposterHeaderDrawBorder{borderColor}
+      \ifcase\baposter@headerbordernr\relax%
+        % open
+        \ifthenelse{\equal{\baposter@headershade}{plain}}{
+          \filldraw  [style=header colors] \baposterHeaderGetShape;%
         }{
-          \fill[box colors] (\baposter@box@name tnw) -- (\baposter@box@name sw) -- (\baposter@box@name se) -- (\baposter@box@name tne);%
+          \shadedraw [style=header colors] \baposterHeaderGetShape;%
         }
-        \draw[color=borderColor] (\baposter@box@name tnw) -- (\baposter@box@name sw) -- (\baposter@box@name se) -- (\baposter@box@name tne);%
-        \end{scope}%
-      }{\ifthenelse{\equal{\baposter@textborder}{rounded}}  {%
-        \ifthenelse{\equal{\baposter@boxshade}{none}}{%
+      \or 
+        % closed
+        \ifthenelse{\equal{\baposter@headershade}{plain}}{
+          \filldraw  [style=header colors] \baposterHeaderGetShape -- cycle;%
         }{
-          \fill[box colors,rc] (\baposter@box@name tnw) -- (\baposter@box@name sw) -- (\baposter@box@name se) -- (\baposter@box@name tne);%
+          \shadedraw [style=header colors] \baposterHeaderGetShape -- cycle;%
         }
-        \draw[color=borderColor,rc] (\baposter@box@name tnw) -- (\baposter@box@name sw) -- (\baposter@box@name se) -- (\baposter@box@name tne);%
-      }{\ifthenelse{\equal{\baposter@textborder}{roundedleft}}  {%
-        \ifthenelse{\equal{\baposter@boxshade}{none}}{%
+      \or
+        % none
+        \ifthenelse{\equal{\baposter@headershade}{plain}}{
+          \fill      [style=header colors] \baposterHeaderGetShape;%
         }{
-          \fill[box colors] (\baposter@box@name tnw) {[rc]-- (\baposter@box@name sw)} -- (\baposter@box@name se) -- (\baposter@box@name tne) -- cycle;%
+          \shade     [style=header colors] \baposterHeaderGetShape;%
         }
-        \draw[color=borderColor,box colors] (\baposter@box@name tnw) {[rc]-- (\baposter@box@name sw)} -- (\baposter@box@name se) -- (\baposter@box@name tne);%
-      }{\ifthenelse{\equal{\baposter@textborder}{faded}}{%
-        \tikzstyle{west faded bar}=[color=borderColor]%
-        \tikzstyle{east faded bar}=[color=borderColor]%
-        \begin{scope}[west faded bar,x={(\baposter@box@name tnw)},y={(\baposter@box@name sw)}]%
-          \draw [draw opacity=1.0,west faded bar] (1.0,0.0) -- (0.9,0.1);%
-          \draw [draw opacity=0.9] (0.9,0.1) -- (0.8,0.2);%
-          \draw [draw opacity=0.8] (0.8,0.2) -- (0.7,0.3);%
-          \draw [draw opacity=0.7] (0.7,0.3) -- (0.6,0.4);%
-          \draw [draw opacity=0.6] (0.6,0.4) -- (0.5,0.5);%
-          \draw [draw opacity=0.5] (0.5,0.5) -- (0.4,0.6);%
-          \draw [draw opacity=0.4] (0.4,0.6) -- (0.3,0.7);%
-          \draw [draw opacity=0.3] (0.3,0.7) -- (0.2,0.8);%
-          \draw [draw opacity=0.2] (0.2,0.8) -- (0.1,0.9);%
-          \draw [draw opacity=0.1] (0.1,0.9) -- (0.0,1.0);%
-        \end{scope}%
-  %
-        \begin{scope}[east faded bar,x={(\baposter@box@name tne)},y={(\baposter@box@name se)}]%
-          \draw [draw opacity=1.0] (1.0,0.0) -- (0.9,0.1);%
-          \draw [draw opacity=0.9] (0.9,0.1) -- (0.8,0.2);%
-          \draw [draw opacity=0.8] (0.8,0.2) -- (0.7,0.3);%
-          \draw [draw opacity=0.7] (0.7,0.3) -- (0.6,0.4);%
-          \draw [draw opacity=0.6] (0.6,0.4) -- (0.5,0.5);%
-          \draw [draw opacity=0.5] (0.5,0.5) -- (0.4,0.6);%
-          \draw [draw opacity=0.4] (0.4,0.6) -- (0.3,0.7);%
-          \draw [draw opacity=0.3] (0.3,0.7) -- (0.2,0.8);%
-          \draw [draw opacity=0.2] (0.2,0.8) -- (0.1,0.9);%
-          \draw [draw opacity=0.1] (0.1,0.9) -- (0.0,1.0);%
-        \end{scope}%
-      }{\ifthenelse{\equal{\baposter@textborder}{rounded-small}}  {%
-        \begin{scope}[color=borderColor,src]%
-          \draw[color=borderColor,box colors] (\baposter@box@name tnw) -- (\baposter@box@name sw) -- (\baposter@box@name se) -- (\baposter@box@name tne);%
-        \end{scope}%
-      }{%
-        \PackageError{baposter.cls}{Unknown text-box style \baposter@textborder}{Edit your file to choose a valid option}}{}
-      }}}}}}}}%
-  %
-      \typeout{Drawing Text}%
+      \fi
+      %
+      %% Draw the text inside the box header:
+      \baposterHeaderDrawText{\color{headerFontColor}\baposter@headerfont{\baposter@box@title}};%
+      %
+      %% Text borders (border around boxes)
+      \debug{Poster boxes}%
+      % First set box shade
+      \baposterBoxDrawBackground{boxColorOne}{boxColorTwo}
+      \baposterBoxDrawBorder{borderColor}
+      %%
       %% Text Box%
-      \path (\baposter@box@name tnw) node(text) [anchor=north west,outer sep=-0.000em,text width=\boxwidth-1em,inner sep=0.5em,text justified] {\usebox{\baposter@content}};%
+      \debug{Drawing Text}%
+      \path (\baposter@box@name tnw) node(text) [anchor=north west,
+            outer sep=-0.000em,text width=\boxwidth-2\baposter@@boxpadding,inner sep=\baposter@@boxpadding,
+            text justified] {\usebox{\baposter@content}};%
     \end{scope}
-  }%
+    %
+    % Finally store the box name as the previous box for the next call
+%     \xdef\@@previousbox{\baposter@box@name}%
+  }% END of posterbox definition
 %
-  %% Background%
-  \baposterShadedBG%
+  %% Poster Background%
+  \baposterPosterDrawBackground{bgColorOne}{bgColorTwo}%
+  %% Poster header/title
   \hspace{-1.5em}%
   \begin{tikzpicture}[inner sep=0pt,outer sep=0pt,line width=0.05em]%
     \useasboundingbox (0em,0em) rectangle(\textwidth,\textheight);%
@@ -788,12 +967,12 @@
       (0pt,\colheight) coordinate(north west) (\textwidth,\colheight) coordinate(north east)%
       (0pt,0pt) coordinate(south west)        (\textwidth,0pt) coordinate(south east);%
 %
-    \ifthenelse{\equal{\baposter@eyecatcher}{no}}{ % Has no eye catcher
-      \setbox\baposter@titleimage@left=\hbox{}%
-    }{ % Has eye catcher%
-      \typeout{Eyecatcher found!}
+    \ifbaposter@eyecatcher% Has eye catcher
+      \debug{Eyecatcher found!}
       \setbox\baposter@titleimage@left=\hbox{#2}%
-    }%
+    \else% Has no eye catcher%
+      \setbox\baposter@titleimage@left=\hbox{}%
+    \fi%
     \setlength{\baposter@titleimage@left@width}{\wd\baposter@titleimage@left}%
     \setbox\baposter@titleimage@right=\hbox{#5}%
     \setlength{\baposter@titleimage@right@width}{\wd\baposter@titleimage@right}%
@@ -801,15 +980,14 @@
     \addtolength{\baposter@titleimage@textwidth}{-\baposter@titleimage@left@width}%
     \addtolength{\baposter@titleimage@textwidth}{-\baposter@titleimage@right@width}%
 
-    \typeout{#3}
+    \debug{#3}
     %
     %
     %      % Draw Header%
     \draw (north west) +(0em,1em+0.5\headerheight) node(image)[anchor=west]   { {\usebox{\baposter@titleimage@left }} };%
     \draw (north east) +(0em,1em+0.5\headerheight) node(logo) [anchor=east]   { {\usebox{\baposter@titleimage@right}} };%
-    \ifthenelse{\equal{\baposter@eyecatcher}{no}}{ % Has no eye catcher
-      \draw (image.east) node(title)[anchor=west]  { {\begin{minipage}{\baposter@titleimage@textwidth}{\bf\Huge #3}\\{\Large #4}\end{minipage}} };%
-    }{ % Has eye catcher%
+    %
+    \ifbaposter@eyecatcher% Has eye catcher%
       \draw (image.east) node(title)[anchor=west,text width=\baposter@titleimage@textwidth]{%
         \begin{minipage}{\baposter@titleimage@textwidth}%
           \begin{center}%
@@ -818,36 +996,30 @@
           \end{center}%
         \end{minipage}
       };%
-    }%
-  }%
+    \else% Has no eye catcher
+      \draw (image.east) node(title)[anchor=west]  { {\begin{minipage}{\baposter@titleimage@textwidth}{\bf\Huge #3}\\{\Large #4}\end{minipage}} };%
+    \fi
+  }% END poster begin
 % The body
-  {%
+  {% BEGIN poster end
     % The end, draw gridlines if neccesary
-    \ifthenelse{\equal{\baposter@grid}{yes}}{ % TODO: Understand boolean options declaration%
-    \draw[draw=green,draw opacity=0.7] %
-      (0\colwidth,0pt)  -- (0\colwidth,\colheight)%
-      (1\colwidth,0pt)  -- (1\colwidth,\colheight)%
-      (1\colwidth+1\baposter@@colspacing,0pt)  -- (1\colwidth+1\baposter@@colspacing,\colheight)%
-      (2\colwidth+1\baposter@@colspacing,0pt)  -- (2\colwidth+1\baposter@@colspacing,\colheight)%
-      (2\colwidth+2\baposter@@colspacing,0pt)  -- (2\colwidth+2\baposter@@colspacing,\colheight)%
-      (3\colwidth+2\baposter@@colspacing,0pt)  -- (3\colwidth+2\baposter@@colspacing,\colheight)%
-      (3\colwidth+3\baposter@@colspacing,0pt)  -- (3\colwidth+3\baposter@@colspacing,\colheight)%
-      (4\colwidth+3\baposter@@colspacing,0pt)  -- (4\colwidth+3\baposter@@colspacing,\colheight)%
-  %
-      (0pt,0.0\colheight)  -- (\textwidth,0.0\colheight) node[anchor=west] {1.0}%
-      (0pt,0.1\colheight)  -- (\textwidth,0.1\colheight) node[anchor=west] {0.9}%
-      (0pt,0.2\colheight)  -- (\textwidth,0.2\colheight) node[anchor=west] {0.8}%
-      (0pt,0.3\colheight)  -- (\textwidth,0.3\colheight) node[anchor=west] {0.7}%
-      (0pt,0.4\colheight)  -- (\textwidth,0.4\colheight) node[anchor=west] {0.6}%
-      (0pt,0.5\colheight)  -- (\textwidth,0.5\colheight) node[anchor=west] {0.5}%
-      (0pt,0.6\colheight)  -- (\textwidth,0.6\colheight) node[anchor=west] {0.4}%
-      (0pt,0.7\colheight)  -- (\textwidth,0.7\colheight) node[anchor=west] {0.3}%
-      (0pt,0.8\colheight)  -- (\textwidth,0.8\colheight) node[anchor=west] {0.2}%
-      (0pt,0.9\colheight)  -- (\textwidth,0.9\colheight) node[anchor=west] {0.1}%
-      (0pt,1.0\colheight)  -- (\textwidth,1.0\colheight) node[anchor=west] {0.0};%
-    }{%
-    }
+    \ifbaposter@grid
+      \newdimen{\gridpos}
+      \pgfmathsetmacro{\z}{\baposter@columns-1}
+      \foreach \y in {0,...,\z}
+      {
+        \setlength{\gridpos}{\y\colwidth+\y\baposter@@colspacing}
+        \draw[draw=green,draw opacity=0.7] (\gridpos,0pt)  -- (\gridpos,\colheight)
+            (\gridpos+\colwidth,0pt)  -- (\gridpos+\colwidth,\colheight);%
+      }
+      % Horizontal lines, every 0.1:
+      %% Explicitly list all percentages, because with {0.0, 0.1, ..., 1.0} we
+      %% get rounding errors in the displayed numbers!
+      \foreach \y in {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0}
+        \draw[draw=green,draw opacity=0.7] (0pt,\colheight-\y\colheight)  --
+            (\textwidth,\colheight-\y\colheight) node[anchor=west] {\y};%
+    \fi%
   \end{tikzpicture}%
  % \xkvview{}
  \par
-  }%
+  }% END poster end