Some small code cleanups, added some comments