fixed functionality of buttons and cleanup