Further changes, added testing code for debugging