Improve buildsystem to be both simpler and more flexible