Code beautification
on and ~on take lambdas now. Fixed some event handling