Some cleaning up and documentation