Added clock task and fixed a small indexing bug