Updated based on changes from Karsten

Adds debugging