added fitting
removed debug messages
added signal handling