Refactor code. Add MGI source.