(top) corrected type errors
(misc) refactoring to respect code conventions