import a bunch of stuff from evita source

Signed-off-by: Bryan Smith <zarboz@gmail.com>