Fixed a lot of bugs and made the code more compliant
Android standards.