Better inventory handling + some refacto