Borrored some stuff from r00k