Restructured and fixed for building with make