Switch to build subpackage

Move as much build-related code into build subpackage.