Bug fixes and better clock