Add button element.
Fix bugs and refactoring.