A few fixes and improvements, make sure it works for frotnend posting too