Merge pull request #273 from AlexanderSavelyev/fmcs_port_21Feb2014

query optimisation was implemented. Memory leak was fixed. Verbose cosmetic
seg fault was fixed