Added speed measuring. Improved error handling