Added some documentation

Fixed some undefined behavior
Cleaned with go fmt