Cleaned up converter, added protection