helper functions and modifications for easier debugging

helper functions and modifications for easier debugging