clean up some code an try to fix a stack trace.