Changes to makefile (optimization) and sim and algorithm