Ned/refactor useful stuff