Made changes to the cosine matrix creation functions.