translated some of the classes from java - it's a complete mess though
.