Code cleanup and docs review