Editing Functions, removing code, restructuring.

Needs to be tested.