Imported some old code from comlog