Fixed NullPointerException (and a bunch of unused imports)