Refactoring

Taking HLint advices into consideration. Some advices are ignored
intentionally.