Add comments and slight restructure. Closes #692