Final version of third assignment with few bug fixes and improvements