Altered "main" function, structure to allow user flexibility. Beginning to add gi handling.