Refactored the source files and fixed segmentation fault upon start-up.