Add loading template, improve error handling