Final version

Clean code, trim fat, and added stuff from tests