fixed fatal error, really should test more before commiting
minor rearrangement of data in debug