general fixes
optimization and makefile changes