Added autotools build system and fixed a couple of bugs related to packaging.