Cleaned up the code a little 
Backported a couple of things from later tutorials

Signed-off-by: Jurgen Schober <jurgen.schober@pointdesign.com>
Sync

Signed-off-by: Jurgen Schober <jurgen.schober@pointdesign.com>