Added some more comments, fixed some layout issues, removed unused imports and so on.