cleaned up logging, added more documentation