Split off cases file, added more cases, cleaned up code more