Fix bug + rewrite some stuff