Change build structure a bit: put common code in a library.