Fix on close
Add log and javadoc