Implemented configure and fixed misc bugs

1. Fixed argument processing problems.
2. Cleaned up setting library variables.