Removed a lot of unused variables and imports.
Also supressing some warnings with @SuppressWarnings("unchecked")