fix build scripts
fixed mysterious bug
fixed build system