Added comments. Code tidy. Updated for LibGDX 1.3.1