Refactored stuff, fixed typo, working so far.