splitted ambiguous errors code, and fixed spare bugs

@hellais @evilaliv3 please review