Move some put statements around for better output