Heavy refactoring. Added support for Ubuntu Trusty and Debian Wheezy