Initial version, extracted from Karma