Implemented framecap and a proper eventhandler