Very nice code cleanup and documentation, and preconditions encoding