Add length match check for cosine

Closes #6 and cleans up some formatting problems