Improved build process, fixes #278