Code cleanup and update documentation