Fix rank, put everything into class