Made some changes based off of recommendations from a code review, a bit more concise now and fixed a few bugs