Fixes Issues #12, #13 - please check solutions.

Please look over changes and see if they are reasonable or not.