Cleaned up code, added access to original template source, simplified loadString