Refactored code to use returnRequest.

Removed invalidRequest method, using returnRequest instead. Fixed misc issues.