bug fixes and print free memory