code cleanup. removed dead code, unnecessary logging. Made changes suggested by golint. Added comments