Code cleanup, documentation