Cleaned up the code a little for testing timeouts