Bug fix and preparations for testing