Import previously used .cpp/.h files and fix compilation errors