Moved parameter parsing to a more appropriate location

This includes reducing the variable scope to only what is necessary