Tanmay,
As of Selenium 2.44, the codebase has stopped using org.json for its needs and instead relies on using google gson libraries for doing the same. So you may have to refactor the sample code snippet i shared in my blogs to get it to work.
Now coming back to the second part of your query.
On a high level here's what you would need to do :
1. Create a servlet at the Grid level that is going to have all the checks and balances in place wherein if it is queried with a token it would either return true (if the number of concurrent sessions for the given token is within the permissible value) and false if otherwise.
2. Inject this servlet into the grid as mentioned in my blog.
3. Now create the custom proxy wherein the proxy's newSession() would basically query the servlet for the current status [ depending on whether your servlet responds to a GET or a POST ] and if the servlet responds with a true, it would proceed further with a session creation and if false it would return back a null session. Invoking the servlet would be merely doing a GET/POST to
http://localhost:4444/grid/admin/<ServletName>
You actually dont need a custom servlet and you can achieve the same thing using a utility class that step (3) can query as well.