Cleaned up and tested. Working basic version