Added missing compile time flags and cleaned up makefiles.
Updated to test threading.
Merge branch 'origin-master'