Cleaned up the code a little bit, to allow for greater flexibility
when implementing the one-way/two-way thing.