Move some code
Remove some unsused code