if statements for debug msgs
minor improvements