moved newline functionality to a public method
cleanup
added support for event handlers
added exit function