All functionalities implemeted. TODO: Optimizations