Updated code and documentation as per comments and requests in issues