Added cosine window function for alignment. Minor fixes