attach, button: remove redundant code, fix codestyle