some fixes and gentoo support

Sorry for short description but I think the code should explain all fixes at best.