General cleanup of code and comments