Contrib branch

Added bugfixes adapting the changes from external libraries. Also added the external libraries as submodules.