Complete refactor of source code. More in Go style now