fixes some bugs as per review