Incorporated janos's suggestions

See: http://codereview.stackexchange.com/a/61482/52040