Advanced debugging and logging added.