Binding to stdin/stdout added and additional functionality, commenting improved slightly.