Motion template improvements and bug fixes