Fixed some code as suggested by NetBeans hints