More logic, ironing out bugs