Changed PCA and cleaned code