Some cleanup. Added more where tests, specific select tests. Added some comments for clarity.