Error handling is realized

Little bugs fixed.