Fgcp: changes and bug fixes to pass most api tests (rebased)