Second commit. Event handling added. Need to work out a tiny bug.