Fixed Compilation Errors and Refactored a Few Files