fixed a  few bug: template was null sometimes null when rendering and initialize events after rendering wasn't working properly