fixed warnings and errors related to unused import, scope of variables, ...

...need bracers, parameters should be final, only one return, method is not designed for extension.