Update build system and chance to gen_server implementation
Merge branch 'update-build-and-refactor-with-gen_server'