Removed unused code, fixed a few warnings and general code clean