Some fixing and debugging