Multifixes for #761, #764 and #778.
Changed the order of the method calls as it is in vanilla.