Cleanup scripts
Fix a few bugs in configure script