Refactoring stuff to eliminate the divergence between java and cs