Clean up code base

The new warnings of 2.11 made a great deal.

- Removal of unused code
- Change var to val when possible
- Remove unused imports
Fix warnings about postfix operator and reflective calls