Additional error handling and refactoring.
Added marker snippets.