Extending Mantra to support Java, and fixed some issues