added code comments and minor cleanup for model