code cleanup, mostly removing old printfs
refactoring: moved utility functions to utils