#451 Refactor

Refactor and solve medium BUGs