Rewrite cuepoint implementation, fixes #610