Note: I may cross-post on StackOverflow