fixed numerous code problems: #MSG-155 In Progress