Added working implementation, some additional tweaks to come later