Rewrote again for refactorization

Also fixed the next cell error and implemented logging. Ready to
implement more key event actions.
Renamed stuff