some lintian work and code refactor