Make regexp more strict
Correctly recognize end of metadata section