lots of big fixes and optimizations. also added keep_sources after packaging support