Sorry, couln't resist to change the coding style.

Replaced spaces with tabs and moved, the curly braces to the end of the
line and added a space after anonymous functions.
Freed the functions, moved the defaults.

Moved the defaults to the variables at the top and named the anonymous
functions.