ported fixes from rabbit branch and improved makefile