Added two passes in the patcher, fixed references, simplified patcher a bit.