Cleanup and add inline comments