Added timebase and fixed bugs