Adds AbstractHandler and does some refactoring