Added #defines

and other fixes