Cleanup

Refactored some code to increase modularity
Finishing file table management