Seperation of java and c implementation and fixes #1