Makefile courtesy of Oranav, some portability changes