Debugging statements included (should be removed eventually) and bug fixes