Improvements and bugfix for Tomcat use