better error handling, demo cleanup