Refactored stubs. Still needs more testing.