Fixed naming conventions, added debugging and reformatted code to be more
efficient and simple.