Cleanup, changed interface and small bug fix