Bunch of changes inspired by r00k