Clean up debug messages and make java detection working properly