major refactor and add workaround for MPlayerX, Xcode