Added buttons. Some fixes and refactoring