Major bug fixes

Fixed major bugs and cross compatibility issues