Added readline interface
Moved event stuff into its own compilation unit