Added streaming support, heavily based on teaonly's project