fixed bugs and cleaned up compile.py;