Code cleaned and organized. Still need to test it.