Fixed high cpu usage. Fixes #36