Added a lag counter to prevent sleeping if previous frames took to much time, fixes #4