Feature/cleanup

This branch only did tidy cleanups (comments, error message etc).
Tested no regression.