Build framework cleanup, some code cleanup and added support for debian packaging system

Hi. I made these changes for myself and am sharing them with you.

Thanks.