Improved outline handling

Should solve overflow problem in most cases.