Fixed issue with using dict incorrectly, added comments