Revert "Use ncurses instead of hand-made functions"

This reverts commit 6ed7f3ae4baa8eef0f80dc1fdd1bb491be701e78.
Add more log
Add unlikely branch on error