Cleaned up template IM controller code per #325