Device and template cleanups