Revert "merge and stable again"

This reverts commit 02f86ac95e434b7d1b604c82644d56e78af23a54.
Code cleanup and fixes error handling