Clean implementation of errno variable.
Fix style and format of some source codes
Updates TODOs