time check, better error handling, various improvements